<template>
<div>
  <h1 @click="getAllUser">用户管理</h1>
  <el-table
    :data="user"
    style="width: 100%;">
    <el-table-column
      prop="id"
      label="id"
      width="80">
    </el-table-column>
    <el-table-column
      prop="name"
      label="账户"
      width="180">
    </el-table-column>
    <el-table-column
      prop="nikeName"
      label="名字"
      width="100">
    </el-table-column>
    <el-table-column
      prop="age"
      label="年龄"
      width="100">
    </el-table-column>
    <el-table-column
      prop="gender"
      label="性别(0男，1女)"
      width="80">
    </el-table-column>
    <el-table-column
      prop="phone"
      label="手机号"
      width="180">
    </el-table-column>
    <el-table-column
      prop="addr"
      label="地址"
      width="180">
    </el-table-column>
    <el-table-column
      prop="status"
      label="认证状态"
      width="80">
    </el-table-column>
    <el-table-column
      prop=""
      label="操作"
      width="200">
      <template slot-scope="scope">
        <el-button
          size="mini"
          type="success"
          v-if="scope.row.status === 0"
          @click="lockOrUnlock(scope.row.id,1)">认证
        </el-button>
        <el-button
          size="mini"
          type="danger"
          v-if="scope.row.status === 1"
          @click="lockOrUnlock(scope.row.id,0)">撤销
        </el-button>
      </template>

    </el-table-column>
  </el-table>
</div>
</template>

<script>
export default {
  name: "UserManager",
  data() {
    return {
      user: {
        id: '',
        name: '',
        status: '',
        nikeName: '',
        phone: '',
        addr: '',
        age: '',
        gender: ''
      },
      search: ''
    }
  },
  created() {
    this.getAllUser()
  },
  methods: {
    //认证用户
    lockOrUnlock(id,status){
      this.$axios({
        method: 'get',
        url: '/admin/lockOrUnlock',
        params: {
          id,
          status
        }
      }).then(res => {
        alert(res.data.message)
      })
    },
    getAllUser(){
      this.$axios({
        method: 'get',
        url: '/admin/getAllUser',
      }).then(res => {
        this.user = res.data.data.data
      })
    }

  }
}
</script>

<style scoped>

</style>
